package com.anolesoft.yr.mbus.prod.model.sql;

public class ProdServiceSQL {

    //根据主键查询产品服务项数据
    public static final String QUERY_PROD_SERVICE_BY_UID = "select a.objuid,a.prod_base_service_uid,a.service_code,a.service_name,a.import_type,case when a.is_timeliness=0 then '否' else '是' end is_timeliness,a.remark from prod_service a where a.del_flag=0 and a.prod_production_uid=#{objuid} order by a.service_name asc";

    //根据主键查询产品服务项唯一数据
    public static final String QUERY_PROD_SERVICE_BY_UID2 = "select a.objuid,a.service_code,a.service_name,a.import_type,case when a.is_timeliness=0 then '否' else '是' end is_timeliness,a.remark from prod_service a where a.del_flag=0 and a.objuid=#{objuid} order by a.service_name asc";

    //删除产品服务项信息
    public static final String DELETE_PROD_SERVICE = "update prod_service a set a.del_flag=1 where a.prod_production_uid=#{objuid}";

    //新增产品服务项信息表
    public static final String SAVE_PROD_SERVICE = "insert into prod_service(objuid,fac_code,prod_production_uid,prod_base_service_uid,service_no,service_code,service_name,import_type,is_timeliness,remark,c_user_uid,c_time,del_flag) values(#{objuid},#{facCode},#{prodProductionUid},#{prodBaseServiceUid},#{serviceNo},#{serviceCode},#{serviceName},#{importType},#{isTimeliness},#{remark},#{ccUserUid},#{ccTime},#{delFlag})";

    //修改产品服务项信息表
    public static final String UPDATE_PROD_SERVICE = "update prod_service a set a.fac_code=#{facCode},a.prod_production_uid=#{prodProductionUid},a.prod_base_service_uid=#{prodBaseServiceUid},a.service_no=#{serviceNo},a.service_code=#{serviceCode},a.service_name=#{serviceName},a.import_type=#{importType},a.is_timeliness=#{isTimeliness},a.remark=#{remark},a.m_user_uid=#{mmUserUid},a.m_time=#{mmTime} where a.objuid=#{objuid}";

    //删除产品服务项信息
    public static final String DELETE_PROD_SERVICE2 = "<script> update prod_service a set a.del_flag=1 where a.prod_production_uid=#{prodProductionUid} and a.objuid not in <foreach collection='prodServiceDeleteDTOList' open='(' item='prodService' separator=',' close=')'> #{prodService.objuid}</foreach> </script>";

    //根据主键查询产品服务项名称
    public static final String QUERY_PROD_SERVICE_NAME_BY_UID = "select a.objuid,a.service_name from prod_service a where a.del_flag=0 and a.prod_production_uid=#{objuid} order by a.service_name asc";

    //根据主键查询产品服务项唯一数据
    public static final String QUERY_PROD_SERVICE_BY_UID3 = "select a.* from prod_service a where a.del_flag=0 and a.objuid=#{objuid} order by a.service_name asc";

    //查询产品服务项名称
    public static final String QUERY_PROD_SERVICE_NAME = "select a.objuid,a.service_name from prod_service a inner join prod_production b on b.objuid=a.prod_production_uid where a.del_flag=0 and b.prod_name=#{prodName} order by a.service_name asc";

}
